<?php
require_once 'PHPUnit/Framework.php';
class ArrayTest extends PHPUnit_Framework_TestCase
{
    function testNewArrayIsEmpty(){
        $data = array();
        $this->assertEquals(0, sizeof($data));        
    }    

    function test_insert_arrays(){
        $data = array();
        $data[] = 'Element0';
        $this->assertEquals(1, sizeof($data));
        $this->assertEquals('Element0',$data[0]);
        $data[] = 'Element1';
        $this->assertEquals(2, sizeof($data));
        $this->assertEquals('Element1',$data[1]);
        
        $data['key1']='data1';
        $this->assertEquals(3, sizeof($data));
        $this->assertEquals('data1',$data['key1']);
    }
    
    function test_about_array_key_exists(){
    	$data = array('startKey');    	
    	$this->assertEquals(false,in_array('key',$data));
    	$this->assertEquals(true,in_array('startKey',$data));    	
    	
    	$data['key'] = '데이타를 넣는다.';
    	$this->assertEquals(false,in_array('key',$data));    	    	
    	$this->assertEquals(true,array_key_exists('key',$data));
    	
    	unset($data['key']); // 키제거 
    	$this->assertFalse(array_key_exists('key',$data));    	
    	$this->assertFalse(array_key_exists('nokey',$data));    	
    }    
}
?>